package br.com.skytef.beans.WEB;

import java.sql.SQLException;
import java.util.List;
import java.util.TimeZone;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.ViewScoped;

import br.com.skytef.dao.DaoReportTicket;
import br.com.skytef.entity.RelatTicketsEntity;
import br.com.skytef.utils.Dates;

/**
 * 
 * @author denilson dias
 * 
 */
@ManagedBean(name = "RelatMovimentacoesBean")
@ViewScoped
public class RelatMovimentacoes {
	private List<RelatTicketsEntity> movVihicle;
	private TimeZone timeZone = TimeZone.getDefault();
	private java.util.Date iniDate;
	private java.util.Date finDate;
	
	@PostConstruct
	public void init() throws SQLException{
		this.load();
	}
	
	public void load() {
		try {
			
			if (iniDate==null)
				iniDate = new java.sql.Date(System.currentTimeMillis());
			
			if (finDate==null)
				finDate = new java.sql.Date(System.currentTimeMillis());
			
			java.sql.Date ini = Dates.dateUtilToSql(iniDate);
			java.sql.Date fin = Dates.dateUtilToSql(finDate);
			DaoReportTicket dao = new DaoReportTicket();
			movVihicle = dao.selectTicketMov(ini, fin);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void refresh() {
		System.out.println("refresh");
		this.load();
	}

	/*------------------------------------------------------------------------------------------
	 * Settes and getters
	 ------------------------------------------------------------------------------------------*/

	public List<RelatTicketsEntity> getMovVihicle() {
		return movVihicle;
	}

	public void setMovVihicle(List<RelatTicketsEntity> movVihicle) {
		this.movVihicle = movVihicle;
	}

	public TimeZone getTimeZone() {
		return timeZone;
	}

	public void setTimeZone(TimeZone timeZone) {
		this.timeZone = timeZone;
	}

	public java.util.Date getIniDate() {
		return iniDate;
	}

	public void setIniDate(java.util.Date iniDate) {
		this.iniDate = iniDate;
	}

	public java.util.Date getFinDate() {
		return finDate;
	}

	public void setFinDate(java.util.Date finDate) {
		this.finDate = finDate;
	}


}
